<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>选课系统-学院列表</title>

		<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
		<!-- Custom styles for this template -->
		<link th:href="@{/css/dashboard.css}" rel="stylesheet">

		<script th:src="@{/js/bootstrap.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/jquery-3.2.1.js}"></script>
		<script type="text/javascript">

			function queryCollegePaging(pageNum){
				$.ajax({
					type: "POST",
					url:"/admin/queryCollegePaging",
					data:{'pageNum':pageNum},
					success:function (data) {
						var tBody=$("#CollegeList");
						tBody.empty();//清空tbody中原有内容
						data.list.forEach((col)=>{
							tBody.append(
									`<tr>
									<td>${col.collegeId}</td>
									<td>${col.collegeName}</td>
							</tr>`
							);
						});
						var paging=$("#paging");
						paging.empty();
						paging.append(
							`<ul class="paging">
								<li><a onclick="queryCollegePaging(${1})" href="#">首页</a></li>
								<li><a onclick="queryCollegePaging(${data.hasPreviousPage? data.pageNum-1 : data.pageNum})" href="#">上一页</a></li>
								<li><a>当前${data.pageNum}页 共${data.navigateLastPage}页</a></li>
								<li><a onclick="queryCollegePaging(${data.hasNextPage? data.pageNum+1 : data.pageNum})" href="#">下一页</a></li>
								<li><a onclick="queryCollegePaging(${data.navigateLastPage})" href="#">末页</a></li>
							</ul>`
						);


					},
					error : function(e){
						console.log(e.status);
						console.log(e.responseText);
					}
				});
			}
		</script>


	</head>

	<body>
	<div th:replace="~{commons::topbar}"></div>

		<div class="container-fluid">
			<div class="row">
				<div th:replace="~{commons::sidebar(active='college')}"></div>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">


					<br>

					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th>id</th>
									<th>学院名</th>
								</tr>
							</thead>
							<tbody id="CollegeList">
								<tr th:each="col:${colleges.getList()}">
									<td th:text="${col.getCollegeId()}"></td>
									<td th:text="${col.getCollegeName()}"></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div id="paging">
						<ul class="paging">
							<li><a th:href="|javascript:queryCollegePaging(1)|">首页</a></li>
							<li><a th:href="|javascript:queryCollegePaging(${colleges.hasPreviousPage? colleges.pageNum-1 : colleges.pageNum})|">上一页</a></li>
							<li><a>当前[[${colleges.pageNum}]]页 共[[${colleges.navigateLastPage}]]页</a></li>
							<li><a th:href="|javascript:queryCollegePaging(${colleges.hasNextPage? colleges.pageNum+1 : colleges.pageNum})|">下一页</a></li>
							<li><a th:href="|javascript:queryCollegePaging(${colleges.navigateLastPage})|">末页</a></li>
						</ul>
					</div>
				</main>
			</div>
		</div>

	</body>

</html>